#lang rosetta-racket


(require "balconies.rkt")

(provide slab-example
         handrail-example
         guard-example
         saw-balcony-example
         oscillator-balcony-example
         sinusoidal-balcony-example)


(define (slab-example)
  (slab
   u0
   (λ (x) (saw 0 0.3 (* 3 pi) x))
   0 (* 4 pi) 0.5 4 1))

(define (handrail-example)
  (handrail
   u0
   (λ (x) (saw 0 0.3 (* 3 pi) x))
   0 (* 4 pi) 0.5 4 0.2 0.3))

(define (guard-example)
  (guard
   u0
   (λ (x) (saw 0 0.3 (* 3 pi) x))
   0 (* 4 pi) 0.5 4 1 0.2 0.3 1))


(define (saw a b c x)
  (abs (+ a (* b (- x c)))))

(define (saw-balcony-example)
  (let ((shape
         (balcony
          u0
          (λ (x) (saw 0 0.3 (* 3 pi) x))
          0 (* 4 pi) 0.5
          4 0.2 1 0.04 0.02 0.4)))
    (view
     (xyz 14.399477038107065 -11.872342346329816 7.734700371040294)
     (xyz 6.30492434820858 0.5842879473187881 -1.4720793437087742)
     (perspective 50)
     shape)))


(define (oscillator a b c x)
  (* a (exp (- (* b x))) (sin (* c x))))

(define (oscillator-balcony-example)
  (let ((shape (balcony
                (xy 8 8)
                (λ (x) (oscillator -2 0.1 2 x))
                0 (* 4 pi) 0.2
                4 0.2 1 0.04 0.02 0.2)))
    (view
     (xyz 22.986166424791442 -7.787506523885437 9.335914680539696)
     (xyz 13.732876922399686 6.452292850728256 -1.1888173644609825)
     (perspective 50)
     shape)))


(define (sinusoidal a ω φ x)
  (* a (max -0.6 (min 0.6 (sin (+ (* ω x) φ))))))

(define (sinusoidal-balcony-example)
  (let ((shape (balcony
                (xy 16 16)
                (λ (x) (sinusoidal 1 1 0 x))
                0 (* 4 pi) 0.2
                4 0.2 1 0.04 0.02 0.4)))
    (view
     (xyz 30.719540611058598 1.5595345555452234 8.951306558166207)
     (xyz 21.645122487903855 15.524070462660433 -1.3699763959459919)
     (perspective 50)
     shape)))